radians
As is normal for most calculators (and most programming languages), the arguments for Java's trigonometric functions are in radians. Unlike most calculators, you can't push a button and switch to degrees. Here is an example program:
import java.io.*;
class CosineCalc
{
public static void main (String[] args)
{
double value;
Scanner scan = new Scanner( System.in );
System.out.print("Enter radians:");
value = scan.nextDouble();
// calculate its cosine
double result = Math.cos( value );
// write out the result
System.out.println("cosine: " + result );
}
}
Here is an example run:
C:\chap11>java CosineCalc Enter radians:1.5 cosine: 0.0707372016677029
What do you suspect are the types of the argument and return value
for Math.cos()
?